<style lang="scss">
  @import 'index';
</style>

<template>
  <div class="ga-container">
    <div class="ga-nearbyStore">
      <h1 class="h1">当前位置：<span class="gOrange">{{address}}</span></h1>
      <div class="h2 gOrange">重庆门店中心</div>

      <a class="pos-item" :href="'../nearbyShopDetail/main?id=' + item.id" v-for="(item,index) in nearbylist" :key="index">
        <p class="p1"><i class="gaIcon icon-map-marker"></i>{{item.nearby_name}}</p>
        <p class="p2">地址:{{item.address}}</p>
        <p class="p3">电话:{{item.telephone}}</p>
        <p class="p4">时间:{{item.business_hours}}</p>
      </a>

      <!-- <p class="txt-center mt50">
        <i class="gaIcon icon-phone-square f28"></i>
      </p>
      <p class="txt-center">023-125-456-888</p>
      <p class="txt-center mt10">
        <i class="gaIcon icon-clock-o f28"></i>
      </p>
      <p class="txt-center">周一到周日9:00-10:00</p> -->
    </div>
  </div>
</template>

<script>
import {isLogin} from '@/utils/handleLogin'
export default {

  data () {
    return {
        address: '',
        nearbylist: [],
    }
  },
  methods: {
    async getLocation () {
       let that = this
       wx.getLocation({
        type: 'wgs84',
        success: function(res) {
          let params = {
            latitude: res.latitude,
            longitude: res.longitude
          }
          that.$_util.ajax.get('https://guo-a.com/mapi/api/geocoder',params).then((res) => {
             if(res.code === 200){
              that.address = res.address
             }
          })
        }
      })
    },
    async load () {
       this.$_util.ajax.get('https://guo-a.com/mapi/nearby/nearbylist?sid='+this.$store.state.sid).then((res) => {
          console.log(res)
          if(res.code === 200){
             this.nearbylist = res.data
          }
       })
    }
  },
  onShow () {
    this.load()
    // isLogin(() => {
    //   this.load()
    // })
  },
  created () {
    this.getLocation()
  }
}
</script>
